/**
 *@Description
 *@author your name
 *@createDate 2011-7-1 下午07:05:53
 *@version V1.0
 */
package com.welldone.util;

public class CommonUtil {

	/**
	 * 判断字符串是否为空，用于拼接SQL
	 *@author your name
	 *@createDate 2011-7-1
	 *@param str
	 *@param prefix
	 *@return
	 */
	public static String escapeNullForSql(Object str,boolean prefix){
		
		if(null==str ||"".equals(str)){
			
			if(prefix){
				return null+",";
			}else{
				return null;
			}
		}else{
			if(prefix){
				return str+",";
			}else{
				return str.toString();
			}
		}
	}
	
	/**
	 * 判断时间字符串是否为空，用于拼接SQL
	 *@author your name
	 *@createDate 2011-7-1
	 *@param str
	 *@param formatString
	 *@param prefix
	 *@return
	 */
	public static String escapeNullDateForSql(Object str,String formatString,boolean prefix){
		if(null==str ||"".equals(str)){
				
				if(prefix){
					return null+",";
				}else{
					return null;
				}
			}else{
				if(prefix){
					return "to_date('"+str+"','"+formatString+"')"+",";
				}else{
					return "to_date('"+str+"','"+formatString+"')";
				}
			}
	}
	
	/**
	 * 判断是否为空
	 *@author your name
	 *@createDate 2011-7-8
	 *@param obj
	 *@return
	 */
	public static boolean equalsNotNull(Object obj){
		if(null==obj){
			return  false;
		}else{
			return true;
		}
	}
	
	
	
	
	public static void main(String args[]){
		System.out.println(escapeNullDateForSql("2010-01-02","yyyy-mm-dd",true));
	}
	
	
}


